package licode.unisop.client.feign;

import licode.unisop.client.utils.SopAuthConst;
import licode.unisop.client.utils.SopResult;
import licode.unisop.client.vo.SopAsset;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 登录外部调用封装
 *
 * @author licode
 */
@FeignClient(name = "${uni-sop.service:uni-auth-service}", url = "${uni-sop.host:}")
public interface SoAssetRelVisitFeign {
    @RequestMapping(value = "/uni-center/v1/internal/asset/save", method = RequestMethod.POST)
    SopResult<Object> save(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                           @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                           @RequestBody Map<String, Object> asset);

    /**
     * 把资源移动到目标资源下（改变其父节点）
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/move", method = RequestMethod.POST)
    SopResult<Object> move(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                           @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                           @RequestBody Map<String, Object> req);

    /**
     * 删除资源
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/delete", method = RequestMethod.POST)
    SopResult<Object> delete(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                             @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                             @RequestBody Map<String, Object> req);

    /**
     * 保存资源持有信息（比如保存分组下的权限信息）
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/relation/of-holder/save", method = RequestMethod.POST)
    SopResult<Object> saveAssetsOfHolder(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                         @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                         @RequestBody Map<String, Object> req);

    /**
     * 移除持有的资源（比如移除分组下的权限信息）
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/relation/of-holder/remove", method = RequestMethod.POST)
    void removeAssetsOfHolder(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                              @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                              @RequestBody Map<String, Object> req);

    /**
     * 保存资源持有信息（比如保存持有权限的所有资源信息（比如分组、角色、用户等））
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/relation/to-holder/save", method = RequestMethod.POST)
    SopResult<Object> saveHoldersOfAsset(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                         @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                         @RequestBody Map<String, Object> req);

    /**
     * 保存资源属性
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/attribute/save", method = RequestMethod.POST)
    SopResult<Object> saveAttributesOfAsset(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                            @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                            @RequestBody Map<String, Object> req);

    /**
     * 移除资源属性
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/attribute/remove", method = RequestMethod.POST)
    SopResult<Object> removeAttributesOfAsset(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                              @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                              @RequestBody Map<String, Object> req);

    // ------------------------------ 查询接口
    /**
     * 分页查询平台资源信息
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/query/page", method = RequestMethod.POST)
    SopResult<Object> queryPage(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                @RequestBody Map<String, Object> req);

    /**
     * 分页查询平台可移动资源信息
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/query/move/page", method = RequestMethod.POST)
    SopResult<Object> queryMovePage(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                    @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                    @RequestBody Map<String, Object> req);

    /**
     * 按层级获取指定类型的资源
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/query/level/all", method = RequestMethod.POST)
    SopResult<Object> queryAllByLevel(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                      @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                      @RequestBody Map<String, Object> req);

    /**
     * 按层级分页查询资源信息，必须传入父资源ID，如果父资源ID为空，则查询顶层所有资源
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/query/level/page", method = RequestMethod.POST)
    SopResult<Object> queryPageByLevel(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                       @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                       @RequestBody Map<String, Object> req);

    /**
     * 分页查询指定资源拥有的所有资源信息，比如查询指定分组下所有的权限信息
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/relation/of-holder/page", method = RequestMethod.POST)
    SopResult<Object> queryAssetsOfHolderPage(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                              @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                              @RequestBody Map<String, Object> req);

    /**
     * 分页查询拥有指定资源的所有资源信息，比如查询拥有指定权限的所有分组信息
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/relation/to-holders/page", method = RequestMethod.POST)
    SopResult<Object> queryHoldersOfAssetPage(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                              @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                              @RequestBody Map<String, Object> req);

    /**
     * 读取资源属性
     */
    @RequestMapping(value = "/uni-center/v1/internal/asset/query/attribute/load", method = RequestMethod.POST)
    SopResult<Map<String, Object>> loadAttributesOfAsset(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                                         @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                                         @RequestBody Map<String, Object> req);

    @RequestMapping(value = "/plat-api/v1/internal/platform/asset/query/lookup-asset/by-code", method = RequestMethod.POST)
    SopResult<SopAsset> lookupAssetByCode(@RequestParam(SopAuthConst.PLATFORM_TOKEN) String platId,
                                          @RequestParam(SopAuthConst.MODAL_TOKEN) String mToken,
                                          @RequestBody Map<String, Object> req);
}
